const app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		role: '',
		type: '',
		userId: '',
		name: '',
		mobile:'',
		totalObj:{}
	},
	getTotal(){
		let companyId = app.globalData.userInfo.companyData.companyId * 1;
		let id=this.data.userId;
		let api;
		if(this.data.type ==1){
			api="outStockTransactionReport"
		}else{
			api="enterTransactionReport"
		}
		wx.$apis[api](companyId,id).then(res => {
			if(res.data){
				let goodsPrice="totalObj.goodsPrice"
				this.setData({
					totalObj:res.data,
					[goodsPrice]: wx.$getYuan(res.data.goodsPrice)
				})
			}

		}).catch(err => {
			
		})
	},
	

	/**
	 * 生命周期函数--监听页面加载
	 */

	onLoad: function (options) {
		console.log('options', options)
		const userId = options.userId;
		const name = options.name;
		const type = options.type;
		const mobile =options.mobile;
		this.setData({
			userId,
			name,
			role: app.globalData.userInfo.role,
			type,
			mobile
		})
		this.getTotal();
	},
	//动态获取BarTitle
	getBar: function () {
		wx.setNavigationBarTitle({
			title: this.data.name
		})

	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {
		this.getBar()
	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
   onPullDownRefresh() {
    const trading_record = this.selectComponent('.trading_record');
    trading_record.onPullDownRefresh && trading_record.onPullDownRefresh()
  },
  onReachBottom() {
    const trading_record = this.selectComponent('.trading_record');
    trading_record.onReachBottom && trading_record.onReachBottom()
  },

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})